package cn.edu.scau.cmi.chenzehan.client;


import cn.edu.scau.cmi.chenzehan.adapterPattern.classAdpater.PowerAdapter;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.stage.Stage;

public class UiClassAdapter extends Application {

	private Button button1;
	private Button button2;
	private TextArea text;
	@Override
	public void start(Stage primaryStage) throws Exception {
		Parent root = FXMLLoader.load(getClass().getResource("classAdapter.fxml"));
		button1 = (Button)root.lookup("#button1");
		button2 = (Button)root.lookup("#button2");
		text = (TextArea)root.lookup("#text");
		
		button1.setOnAction(e->{
			PowerAdapter pa = new PowerAdapter();
			text.appendText("电池将处于" + pa.output220() + "电压下工作!\n");
		});
		button2.setOnAction(e->{
			PowerAdapter pa = new PowerAdapter();
			text.appendText("电池将处于" + pa.output110() + "电压下工作!\n");
		});
		
		
		
		Scene scene = new Scene(root);
		primaryStage.setScene(scene);
		primaryStage.show();
	}
        
	public static void main(String[] args) {
		launch(args);
	}
}
